<template>
	<view class="index">
		<Search></Search>

		<view class="navlist">
			<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :circular="true" class="swiper">
				<swiper-item v-for="item in swiperlist" :key="item.id" class="swiper-item">
					<image :src="item.src" class="swiper-image"></image>
				</swiper-item>
			</swiper>
		</view>

		<view class="roomList">
			<image src="../../static/index_icon/word1.png" mode="aspectFit" class="yixizhidi"></image>
			<ren-dropdown-filter :filterData='filterData' :defaultIndex='defaultIndex' @onSelected='onSelected' class="rendrop">
			</ren-dropdown-filter>
			<view class="taglist">
				<view v-for="(item,index) in tags" :key="index" class="tag">
					{{item.name}}
				</view>
			</view>
			<view v-for="(item,index) in roomList" :key="item.id" class="rooItem" @click="todetail()">
				<image v-if="item.image" :src="item.image" mode="aspectFill" class="roomImage"></image>
				<view class="right">
					<view class="l1">
						{{ item.name }}
					</view>
					<view class="l2">
						<image src="../../static/index_icon/45star.png" mode="aspectFit" class="imgioc"></image>
						<view class="text">
							上座率: {{item.attendence}}
						</view>
					</view>
					<view class="l3">
						<text>地点：{{item.position}}</text>
					</view>
					<view class="l4">
						<view class="left">
							<text>距离：{{item.distance}}</text>
							<text>时间：{{item.time}}</text>
						</view>
						<view class="right">
							<view class="card">
								<text class="cardwords">[天卡]</text>
								<text class="money">￥{{item.dayprice}}</text>
							</view>
							<view class="card">
								<text class="cardwords">[时卡]</text>
								<text class="money">￥{{item.hourprice}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	//引入子组件
	import RenDropdownFilter from '@/components/ren-dropdown-filter/ren-dropdown-filter.vue'
	import Search from '../../components/search.vue'
	import roomListjs from '@/static/data/roomList.js'
	export default {
		// vue里面引入之后需要注册
		components: {
			RenDropdownFilter,
			Search,
		},
		data() {
			return {
				swiperlist: [{
						id: 0,
						src: '../../static/roomimg/1.jpg'
					},
					{
						id: 1,
						src: "../../static/roomimg/2.jpg"
					},
					{
						id: 2,
						src: "../../static/roomimg/3.jpg"
					}
				],
				tags: [{
						id: 0,
						name: '24h营业'
					},
					{
						id: 1,
						name: '讨论分区'
					},
					{
						id: 2,
						name: '店铺特色'
					},
					{
						id: 3,
						name: '限时优惠'
					}
				],
				filterData: [
					[{
						text: '综合排序',
						value: ''
					}, {
						text: '按距离排序',
						value: 1
					}, {
						text: '按人气排序',
						value: 2
					}, {
						text: '按上座率排序',
						value: 3
					}],
					[{
						text: '筛选',
						value: ''
					}, {
						text: '按距离排序',
						value: 1
					}, {
						text: '按人气排序',
						value: 2
					}, {
						text: '按上座率排序',
						value: 3
					}]
				],
				defaultIndex: [0,0],
				roomList: roomListjs.data,
				objectArray: [{
					id: 0,
					name: 'li ming'
				}, {
					id: 1,
					name: 'wang peng'
				}],
				sortkey: "item.distancenum",
			}
		},
		onLoad() {

		},
		methods: {
			changesort(key) {
				if (key == 1) {

				}
			},
			onSelected(res) {
				changesort(res.value);
			},
			todetail() {
				uni.navigateTo({
					url: "../xiangqing/index"
				})
			}
		}
	}
</script>

<style lang="scss">
	.index {
		background-color: #ffffff;
	}
	.navlist {
		box-sizing: border-box;
		padding: 0 35rpx;
	}
	.swiper {
		margin: 0 auto;
		width: 100%;
		height: 360rpx;
		border-radius: 15rpx !important;
		overflow: hidden;
	}

	.swiper-item {
		border-radius: 15rpx !important;
		overflow: hidden;
	}

	.swiper-image {
		width: 100%;
		height: 360rpx;
		border-radius: 15rpx !important;
	}

	.yixizhidi {
		margin-top: 25rpx;
		margin-bottom: 20rpx;
		height: 54.67rpx;
	}
	.taglist{
		display: flex;
		flex-direction: row;
		width: 100%;
		height: 56.67rpx;
		margin-top: 60rpx;
		justify-content: space-between;
		.tag{
			font-size: 23.33rpx;
			font-weight: bold;
			width: 150rpx;
			display:flex;
			justify-content: center;
			align-items: center;
			color: #000000;
			background-color: #f1f1f1;
			border-radius: 15rpx;
		}
	}

	.roomList {
		background-color: #fff;
		padding: 10rpx 30rpx;
	}

	.rooItem {
		padding: 30rpx 30rpx;
		display: flex;
		height: 180rpx;
		gap: 15rpx;
		margin-top: 15.33rpx;
		border-radius: 25rpx;
		background-color: #FFFFFF;
		box-shadow: 6rpx 8rpx 0px #c9c9c9 ;
		
		.roomImage {
			width: 180rpx;
			height: 180rpx;
		}

		.l1 {
			font-size: 32rpx;
			font-weight: bold;
		}

		.l2 {
			display: flex;
			justify-content: flex-start;
			flex-direction: row;
			align-items: center;
			gap: 20rpx;
			.imgioc {
				height: 26rpx;
				width: 149.76rpx;
			}
			.text {
				height: 30rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				background-color: #f76262;
				color: #FFFDEF;
				padding: 0rpx 10rpx;
				font-size: 25rpx;
				border-radius: 7rpx;
			}
		}

		.l3 {
			display: flex;
			justify-content: flex-start;
			font-size: 28rpx;
			color: #808080;
		}
		
		.l4 {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			width: 680rpx;
			.left{
				height: 100%;
				display: flex;
				flex-direction: column;
				flex-wrap: wrap;
				font-size: 28rpx;
				color: #808080;
			}
			.right{
				display: flex;
				height: 100%;
				flex-direction: column;
				flex-wrap: wrap;
				font-size: 28rpx;
				font-weight: bold;
				.cardwords{
					color: black;
				}
				.money{
					color: #ff5f00;
				}
			}
		}
	}

	.right {
		width: 400rpx;
		height: 180rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}
</style>
